package com.oocl.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.oocl.exception.MyException;
import com.oocl.service.FoodService;
import com.oocl.service.impl.FoodServiceImpl;


public class DeleteFoodServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException {
		String fid = request.getParameter("fid");
		FoodService fSer = new FoodServiceImpl();
		try {
			int count = fSer.delete(fid);
			if(count>0){
				request.getRequestDispatcher("foodlist").forward(request, response);
			}else{
				response.sendRedirect("exception.jsp");
			}
		} catch (MyException e) {
			e.printStackTrace();
		}
	}



	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
        doGet(request,response);
	}

}
